#ifndef __RINGBUFFER_H__
#define __RINGBUFFER_H__
typedef enum {
    REPLACE,
    DROP,
}WriteMode;
typedef struct RING_BUFER{
    char* buffer;
    int size;
    int write;
    int read;
    WriteMode mode;//写数据方式，默认DROP
}RingBuffer;

RingBuffer* new_ring_buffer(int size,WriteMode mode);
void ring_buffer_free(RingBuffer* buffer);
int ring_buffer_write(RingBuffer* buffer,char* data,int size);
int ring_buffer_read(RingBuffer* buffer,char* out,int size);
int ring_buffer_len(RingBuffer* buffer);
int ring_buffer_is_full(RingBuffer* buffer);
int ring_buffer_is_empty(RingBuffer* buffer);
int ring_buffer_clear(RingBuffer* buffer);
void ring_buffer_dump(RingBuffer* buffer);
#endif //__RINGBUFFER_H__